package net.sunofbeach.blog.controller.portal;

import net.sunofbeach.blog.interceptor.CheckTooFrequentCommit;
import net.sunofbeach.blog.pojo.Diary;
import net.sunofbeach.blog.response.ResponseResult;
import net.sunofbeach.blog.services.IDiaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/portal/diary")
public class DiaryPortalApi {

    @Autowired
    private IDiaryService diaryService;

    @CheckTooFrequentCommit
    @PostMapping
    public ResponseResult postDiary(@RequestBody Diary diary) {
        return diaryService.postDiary(diary);
    }

    @GetMapping("/list/{page}/{size}")
    public ResponseResult listDiary(@PathVariable("page") int page,
                                    @PathVariable("size") int size) {
        return diaryService.listDiary(page, size);
    }
}
